<template>
    <s-Home>

        <div class="list">
            <Card style="height: 100%;">
                <div class="purchase">
                    <Button type="primary" @click="modal = true">货物销售</Button>
                    <Modal v-model="modal" title="" :loading="loading" @on-ok="asyncOK">
                        <sales_add></sales_add>
                    </Modal>
                </div>
                <h3 style="text-align: center;font-size: large;margin-bottom: 20px;">销售订单列表</h3>
                <Table :columns="columns1" :data="datasales"></Table>
                <div class="page">
                    <Page :total="total" show-elevator :page-size="pageSize" @on-change="pageChange" show-total></Page>
                </div>
            </Card>
        </div>

    </s-Home>

</template>
<script>
    import api from '../network/api/inventory'
    export default {
        name: 'sales',
        data() {
            return {
                modal: false,
                loading: true,
                total: 0,
                pageSize: 12,
                columns1: [
                    {
                        title: '序列',
                        type: 'index',
                        width:'80'
                    },
                    {
                        title: '订单编号',
                        key: 'shipment_order_num'
                    },
                    {
                        title: '货物编号',
                        key: 'goods_num'
                    },
                    {
                        title: '出货数量',
                        key: 'shipment_quantity'
                    },
                    {
                        title: '出货价格',
                        key: 'shipment_price'
                    },
                    {
                        title: '日期',
                        key: 'shipment_date'
                    },
                    {
                        title: '出货店商',
                        key: 'shipment_shops'
                    },
                    {
                        title: '负责人',
                        key: 'shipment_responsible'
                    }
                ],
                datasales: [],
                alldata: []

            }
        },
        methods: {
            asyncOK() {
                setTimeout(() => {
                    this.modal = false;
                }, 2000);
            },
            //出货订单列表
            shipment() {
                api.getShipment().then(res => {
                    this.alldata = res.data;
                    this.datasales = this.alldata.slice(0, 14);
                    this.total = res.data.length;
                })
            },
            //改变页码回调
            pageChange(index) {
                this.datasales = this.alldata.slice((index - 1) * 14, (index - 1) * 14 + 14)
                console.log('当前页码：' + index);
            },
        },
        created() {
            this.shipment();
        }
    }
</script>
<style>
    .purchase {}

    .list {
        float: left;
    }

    .input {}

    .page {
        text-align: center;
        margin-top: 15px;
    }
</style>